package com.travel.controller;

import com.qianfeng.util.ResultMsg;
import com.travel.entity.TbAdmin;
import com.travel.entity.TbUser;
import com.travel.service.AdminService;
import com.travel.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/adminAdmin")
public class AdminAdminController {
    /**
     * 查询所有管理员
     * */
    @Autowired
    AdminService adminService;
    @GetMapping("/getAllAdmin")
    public ResultMsg getAllAdmin(@RequestParam(required = false,defaultValue = "1") int current, @RequestParam(required = false,defaultValue = "5") int size){
        return adminService.getAllAdmin(current,size);
    }
    /**
     * 通过id查询管理员
     * */
    @GetMapping("/getAdminById/{adminId}")
    public ResultMsg getAdminById(@PathVariable("adminId") int adminId){
        return adminService.getAdminById(adminId);
    }
    /**
     * 修改管理员
     * */
    @PostMapping("/updateAdmin")
    public ResultMsg updateAdmin(@RequestBody TbAdmin tbAdmin){
        return adminService.updateAdmin(tbAdmin);
    }
    /**
     * 添加管理员
     * */
    @GetMapping("/addAdmin")
    public ResultMsg addAdmin(TbAdmin tbAdmin){
        return adminService.addAdmin(tbAdmin);
    }
    /**
     * 删除管理员
     * */
    @GetMapping("/deleteAdmin/{id}")
    public ResultMsg deleteAdmin(@PathVariable("id") int id){
        return adminService.deleteAdmin(id);
    }
}
